import re

# 另一个实际应用：提取多行日志中的特定部分
log_data = """[ERROR] 2023-01-01 10:00:00
    Error details: Connection timeout
    Stack trace:
        at com.example.App.main(App.java:10)
[INFO] Another log entry"""

error_pattern = r"\[ERROR\].*?Stack trace:(.*?)(?=\[|\Z)"
match_error = re.search(error_pattern, log_data, re.DOTALL)
if match_error:
    print("\nError stack trace:", match_error.group(1))


